package  
{
	import bulletbehavior.DieBehavior;
	import bulletbehavior.SplitBehavior;
	import org.flixel.FlxG;
	import turretbehavior.SpinningTurretBehavior;
	import turretbehavior.TypeCyclingTurretBehavior;
	/**
	 * ...
	 * @author morgan
	 */
	public class Stage1State extends GameState
	{
		[Embed (source = "../data/tutorial1.png")] private var tut1:Class;
		[Embed (source = "../data/tutorial2.png")] private var tut2:Class;
		[Embed (source = "../data/tutorial3.png")] private var tut3:Class;
		
		public function Stage1State() 
		{
			super();
			levelName = "1-1";
			levelIndex = 0;
			chefName = "al dente";
			img_clouds1 = img_clouds1_1;
			img_terrain = img_terrain_1;			
		}
		
		override public function setupBoss():void 
		{
			boss = new Boss(FlxG.width / 2 - 70, 10, 0);
			
			var straight:BulletPattern = new BulletPattern();
			var split3_90:BulletPattern = new BulletPattern();
			split3_90.addBehavior(new SplitBehavior(3, 65, 135, 45, straight, -1));
			split3_90.addBehavior(new DieBehavior());
			
			var split24_360:BulletPattern = new BulletPattern();
			split24_360.addBehavior(new SplitBehavior(16, 80, 0, 360 - (360/16), straight, -1));
			split24_360.addBehavior(new DieBehavior());
			
			var burst32:BulletPattern = new BulletPattern();
			burst32.addBehavior(new SplitBehavior(24, 40, 0, 360 - (360/24), straight, -1), 1);
			burst32.addBehavior(new DieBehavior(), 1);
			
			var tut1Pattern:BossPattern = new BossPattern();
			var tut1Turret:Turret = new Turret(0, 0, straight, 0, 90, 50, 1);
			tut1Turret.addBehavior(new TypeCyclingTurretBehavior(6, [0, 1, 2]));
			
			tut1Pattern.addTurretTime(1.5, 20, tut1Turret);
			
			
			var tut2Pattern:BossPattern = new BossPattern();
			var tut2Turret:Turret = new Turret(0, 0, split3_90, 65, 90, 0, 2.0);
			tut2Turret.addBehavior(new TypeCyclingTurretBehavior(2.0, [0, 1, 2]));
			
			tut2Pattern.addTurretTime(1, 6, tut2Turret);
			
			
			var tut3Pattern:BossPattern = new BossPattern();
			var tut3Turret1:Turret = new Turret(0, 0, straight, 0, 90, 80, 0.2);
			tut3Turret1.addBehavior(new TypeCyclingTurretBehavior(0.4, [0, 1, 2]));
			tut3Turret1.addBehavior(new SpinningTurretBehavior(120));

			var tut3Turret2:Turret = new Turret(0, 0, straight, 0, 90, 50, 0.1);
			tut3Turret2.addBehavior(new TypeCyclingTurretBehavior(0.2, [0, 1, 2]));
			tut3Turret2.addBehavior(new SpinningTurretBehavior( -360));
			
			//var tut3Turret3:Turret = new Turret(0, 0, split24_360, 0, 90, 50, 1.01);
			//tut3Turret3.addBehavior(new TypeCyclingTurretBehavior(1, [2, 1, 0]));
			
			tut3Pattern.addTurretTime(0, 5, tut3Turret1);
			tut3Pattern.addTurretTime(5, 10, tut3Turret2);
			//tut3Pattern.addTurretTime(11, 12, tut3Turret3);
			
			var tut4Pattern:BossPattern = new BossPattern();
			var tut4Turret1:Turret = new Turret(30, 0, burst32, 0, 90, 30, 4.5);
			var tut4Turret2:Turret = new Turret(0, 0, burst32, 1, 90, 30, 4.5);
			var tut4Turret3:Turret = new Turret(-30, 0, burst32, 2, 90, 30, 4.5);
			tut4Pattern.addTurretTime(0, Number.MAX_VALUE, tut4Turret1);
			tut4Pattern.addTurretTime(1, Number.MAX_VALUE, tut4Turret2);
			tut4Pattern.addTurretTime(2, Number.MAX_VALUE, tut4Turret3);
			
			boss.addState(new BossState(850, tut1Pattern));
			boss.addState(new BossState(800, tut2Pattern));
			boss.addState(new BossState(1300, tut3Pattern));
			boss.addState(new BossState(1000, tut4Pattern));
			tutorialsEnabled = true;
		}
		
		override public function update():void 
		{
			super.update();
			if (!Saving.showedTut1)
			{
				if (time < 1 && time + FlxG.elapsed >= 1)
				{
					showTutorial(tut1);
					showTutorial(tut2);
					showTutorial(tut3);
					Saving.showedTut1 = true;
				}
				
				if (boss.states.length == 3 && boss.pattern.time <= 1)
				{
					hitboxes = 2.0;
				}
			}
		}
		
	}

}